package sz.szsmk.citizencard.ui.newversion.dialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import androidx.annotation.NonNull
import kotlinx.android.synthetic.main.dialog_logout_confirm.*
import sz.szsmk.citizencard.R
import sz.szsmk.citizencard.util.JumpUtils

/**
 *  author : hyt
 *  date : 2020/10/29
 *  description :
 */
class TokenErrorDialog(@NonNull context: Context) : Dialog(context, R.style.alertdialog) {

    companion object{
         var dialog:TokenErrorDialog?=null

        fun show(mContext:Context){
            if(dialog!=null){
                if(dialog?.isShowing!!){

                }else{
                    dialog?.show()
                }
            }else{
                dialog = TokenErrorDialog(mContext)
                dialog?.show()
            }
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(LayoutInflater.from(context).inflate(R.layout.dialog_tokenerror, null))
        val divierId = context.resources.getIdentifier("android:id/titleDivider", null, null)
        val divider = findViewById<View>(divierId)
        divider.visibility = View.GONE
        initView()
    }

    private fun initView(){
        btn_cancel.setOnClickListener { v: View? -> this@TokenErrorDialog.dismiss() }
        btn_ok.setOnClickListener{
            JumpUtils.jump(context, "login", 0)
            dismiss()
        }
    }

}